home *** CD-ROM | disk | FTP | other *** search
/ Sky at Night 2007 June / SAN CD 6-2007 CD-ROM 25.iso / pc / Software / AstroGrav_Win / Java / jre1.6.0 / lib / rt.jar / java / awt / Component$NativeInLightFixer.class (.txt) < prev    next >
Encoding:
Java Class File  |  2006-11-29  |  2.5 KB  |  141 lines

  1. package java.awt;
  2.  
  3. import java.awt.event.ComponentEvent;
  4. import java.awt.event.ComponentListener;
  5. import java.awt.event.ContainerEvent;
  6. import java.awt.event.ContainerListener;
  7. import java.awt.peer.LightweightPeer;
  8. import java.util.Vector;
  9.  
  10. final class Component$NativeInLightFixer implements ComponentListener, ContainerListener {
  11.    Vector lightParents;
  12.    Container nativeHost;
  13.    // $FF: synthetic field
  14.    final Component this$0;
  15.  
  16.    Component$NativeInLightFixer(Component var1) {
  17.       this.this$0 = var1;
  18.       this.lightParents = new Vector();
  19.       this.install(var1.parent);
  20.    }
  21.  
  22.    void install(Container var1) {
  23.       this.lightParents.clear();
  24.       Container var2 = var1;
  25.  
  26.       boolean var3;
  27.       for(var3 = true; var2.peer instanceof LightweightPeer; var2 = var2.parent) {
  28.          var2.addComponentListener(this);
  29.          var2.addContainerListener(this);
  30.          this.lightParents.addElement(var2);
  31.          var3 &= var2.isVisible();
  32.       }
  33.  
  34.       this.nativeHost = var2;
  35.       var2.addContainerListener(this);
  36.       this.componentMoved((ComponentEvent)null);
  37.       if (!var3) {
  38.          synchronized(this.this$0.getTreeLock()) {
  39.             if (this.this$0.peer != null) {
  40.                this.this$0.peer.hide();
  41.             }
  42.          }
  43.       }
  44.  
  45.    }
  46.  
  47.    void uninstall() {
  48.       if (this.nativeHost != null) {
  49.          this.removeReferences();
  50.       }
  51.  
  52.    }
  53.  
  54.    public void componentResized(ComponentEvent var1) {
  55.    }
  56.  
  57.    public void componentMoved(ComponentEvent var1) {
  58.       synchronized(this.this$0.getTreeLock()) {
  59.          int var3 = this.this$0.x;
  60.          int var4 = this.this$0.y;
  61.  
  62.          for(Container var5 = this.this$0.parent; var5 != null && var5.peer instanceof LightweightPeer; var5 = var5.parent) {
  63.             var3 += var5.x;
  64.             var4 += var5.y;
  65.          }
  66.  
  67.          if (this.this$0.peer != null) {
  68.             this.this$0.peer.setBounds(var3, var4, this.this$0.width, this.this$0.height, 1);
  69.          }
  70.  
  71.       }
  72.    }
  73.  
  74.    public void componentShown(ComponentEvent var1) {
  75.       if (this.shouldShow()) {
  76.          synchronized(this.this$0.getTreeLock()) {
  77.             if (this.this$0.peer != null) {
  78.                this.this$0.peer.show();
  79.             }
  80.          }
  81.       }
  82.  
  83.    }
  84.  
  85.    private boolean shouldShow() {
  86.       boolean var1 = this.this$0.visible;
  87.  
  88.       for(int var2 = this.lightParents.size() - 1; var2 >= 0 && var1; --var2) {
  89.          var1 &= ((Container)this.lightParents.elementAt(var2)).isVisible();
  90.       }
  91.  
  92.       return var1;
  93.    }
  94.  
  95.    public void componentHidden(ComponentEvent var1) {
  96.       if (this.this$0.visible) {
  97.          synchronized(this.this$0.getTreeLock()) {
  98.             if (this.this$0.peer != null) {
  99.                this.this$0.peer.hide();
  100.             }
  101.          }
  102.       }
  103.  
  104.    }
  105.  
  106.    public void componentAdded(ContainerEvent var1) {
  107.    }
  108.  
  109.    public void componentRemoved(ContainerEvent var1) {
  110.       Component var2 = var1.getChild();
  111.       if (var2 == this.this$0) {
  112.          this.removeReferences();
  113.       } else {
  114.          int var3 = this.lightParents.size();
  115.  
  116.          for(int var4 = 0; var4 < var3; ++var4) {
  117.             Container var5 = (Container)this.lightParents.elementAt(var4);
  118.             if (var5 == var2) {
  119.                this.removeReferences();
  120.                break;
  121.             }
  122.          }
  123.       }
  124.  
  125.    }
  126.  
  127.    void removeReferences() {
  128.       int var1 = this.lightParents.size();
  129.  
  130.       for(int var2 = 0; var2 < var1; ++var2) {
  131.          Container var3 = (Container)this.lightParents.elementAt(var2);
  132.          var3.removeComponentListener(this);
  133.          var3.removeContainerListener(this);
  134.       }
  135.  
  136.       this.nativeHost.removeContainerListener(this);
  137.       this.lightParents.clear();
  138.       this.nativeHost = null;
  139.    }
  140. }
  141.